package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dao.CategoryDTO;
import com.sky.dao.CategoryPageDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CategoryMapper {
    Page<Category> page(CategoryPageDTO categoryPageDTO);


    List<Category> list(Integer type);

    @AutoFill(value = OperationType.UPDATE)
    void update(CategoryDTO categoryDTO);

    @Update("update category set status = #{status} where id = #{id}")
    void startOrStop(Integer status, Integer id);

    @Select("select type from category where id = #{id}")
    Integer getType(Integer id);

    @Delete("delete from category where id = #{id}")
    void delete(Integer id);

    @AutoFill(value = OperationType.INSERT)
    void save(Category category);

    @Select("select name from category where id = #{categoryId}")
    String getNameById(Long categoryId);
}
